cmake_minimum_required (VERSION 2.8)

SET (MODULE_NAME cgpuconv)
project(${MODULE_NAME})

IF(UNIX)
  set ( CMAKE_CXX_FLAGS "-Wno-write-strings")
ENDIF(UNIX)

# additional CMake modules
set(CMAKE_MODULE_PATH "${cgpuconv_SOURCE_DIR}/cmake")

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

FILE (GLOB sources
		${CMAKE_CURRENT_SOURCE_DIR}/*.cu
		${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
		${CMAKE_CURRENT_SOURCE_DIR}/*.c
		${CMAKE_CURRENT_SOURCE_DIR}/*.h
		${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
    )



#Support for CUDA Integration
FIND_PACKAGE(CUDA REQUIRED)
if(CUDA_FOUND)
INCLUDE_DIRECTORIES(${CUDA_SDK_ROOT_DIR}/samples/common/inc)
INCLUDE_DIRECTORIES(/Developer/NVIDIA/CUDA-6.0/samples/common/inc)

else(CUDA_FOUND)
    message("CUDA is not installed on this system.")
endif()


FIND_PACKAGE(Boost REQUIRED program_options)
IF (Boost_FOUND)
	INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR})
	LINK_DIRECTORIES( ${Boost_LIBRARY_DIRS})
ENDIF()

FIND_PACKAGE(PortAudio REQUIRED)
IF (PORTAUDIO_FOUND)
	INCLUDE_DIRECTORIES(${PORTAUDIO_INCLUDE_DIR})
	#LINK_DIRECTORIES(${PORTAUDIO_LIBRARY_DIRS})
ENDIF()

FIND_PACKAGE(LibSndFile REQUIRED)
IF (SNDFILE_FOUND)
	INCLUDE_DIRECTORIES(${SNDFILE_INCLUDE_DIR})
	#LINK_DIRECTORIES(${SNDFILE_LIBRARY_DIRS})
ENDIF()

FIND_PACKAGE(FFTW REQUIRED)
IF (FFTW_FOUND)
	INCLUDE_DIRECTORIES(${FFTW_INCLUDE_DIR})
	#LINK_DIRECTORIES(${FFTW_LIBRARY_DIRS})
ENDIF()

FIND_PACKAGE(OpenCL REQUIRED)
IF (OpenCL_FOUND)
	INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIR})
	#LINK_DIRECTORIES(${OPENCL_LIBRARY_DIRS})
ENDIF()


CUDA_ADD_EXECUTABLE(${MODULE_NAME} ${sources})

target_link_libraries(${MODULE_NAME} ${CUDA_CUDA_LIBRARY} ${CUDA_cufft_LIBRARY} ${Boost_LIBRARIES} ${PORTAUDIO_LIBRARIES} ${SNDFILE_LIBRARIES} ${FFTW_LIBRARIES} ${OPENCL_LIBRARIES})